#ifndef TEMPLATEPARSER
#define TEMPLATEPARSER
#include <iostream>
#include <map>
//#include "../../base/TemplateParser/QiParser.h"
//#include "../../base/RequestParser/RequestParser.h"
#include "../../base/TemplateParser/HtmlParser.h"
#include "../../base/Configuration/Configuration.h"


class Template{
	public:
		map<string,boost::any> ViewData;
		void start();
	private:

 };
void Template::start(){
	std::string output="";
	if(RequestParser::type=="web"){
		output+=("Content-type: text/html\n\n");
		//get layout
		if(RequestParser::layout!=""){
			std::string layout=FileProcessor::readFileToString("app/views/layout/"+RequestParser::layout+".ctp");
			//replace content
			string view=FileProcessor::readFileToString("app/views/"+RequestParser::view+".ctp");
			layout=StringProcessor::replace("@echo_content",view, layout);
			//parse layout
			string test="testa";
			map<string,boost::any> t;
			map<string,boost::any> t2;
			t2["a"]=test;
			//t["0"]=t2;
			string test2="2";
			t["1"]=test2;
			ViewData["test"]=t;
			ViewData["t"]=t;

			HtmlParser pasr;
			pasr.ViewData=ViewData;
			output+=pasr.parse(layout);
			output+="Config Data :" + Configuration::myConfig["key"];
			//

			//get view


		}
		//output html:
		std::cout<<output;
	}
}

#endif
